using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Chest : MonoBehaviour, IInteract
{
    InventoryData inventory;
    public InventoryDataSO saveData;
    bool isOpen;
    Animator animator;

    private void Start()
    {
        inventory = GetComponent<InventoryData>();
        animator = GetComponent<Animator>();
        isOpen = false;
    }

    public string Interact(GameObject interactor)
    {
        UIManager.Instance.chestInventory.Open(inventory.data);
        isOpen = !isOpen;
        animator.SetBool("IsOpen", isOpen);
        return "";
    }

    private void OnTriggerExit2D(Collider2D collision)
    {
        UIManager.Instance.chestInventory.Open(inventory.data, false);
    }
}
